/* GUI CONVERTED from rcmbmta.p (converter v1.76) Thu Jul  4 11:42:26 2002 */
/* rcmbmta.p - MASTER BILL MAINTENANCE SUBROUTINE                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.9.1.7 $                                                           */
/*V8:ConvertMode=Maintenance                                             */
/* REVISION: 7.5    LAST MODIFIED: 03/20/95           BY: GWM *J049*          */
/* REVISION: 8.5    LAST MODIFIED: 04/24/96           BY: GWM *J0K8*          */
/* REVISION: 8.5    LAST MODIFIED: 06/11/96           BY: GWM *J0S3*          */
/* REVISION: 8.5    LAST MODIFIED: 07/25/96           BY: jpm *J11D*          */
/* REVISION: 8.6    LAST MODIFIED: 09/09/96           BY: jpm *K00D*          */
/* REVISION: 8.6    LAST MODIFIED: 08/08/96   BY: *K003* Vinay Nayak-Sujir    */
/* REVISION: 8.6    LAST MODIFIED: 03/20/97   BY: *J1LM* Ajit Deodhar         */
/* REVISION: 8.6    LAST MODIFIED: 04/02/97   BY: *K09H* Vinay Nayak-Sujir    */
/* REVISION: 8.6    LAST MODIFIED: 12/03/97   BY: *J27H* Nirav Parikh         */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane            */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan           */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan           */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane     */
/* REVISION: 9.1    LAST MODIFIED: 07/19/00   BY: *N0GF* Mudit Mehta          */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown           */
/* Revision: 1.9.1.4     BY: Jean Miller    DATE: 03/22/01 ECO: *P008*       */
/* $Revision: 1.9.1.7 $          BY: R.Satya Narayan    DATE: 06/25/02 ECO: *P086*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/* ********** Begin Translatable Strings Definitions ********* */

{mfdeclre.i} /*GUI moved to top.*/
&SCOPED-DEFINE rcmbmta_p_2 "Master Bill"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_3 "Net Weight"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_4 "Bill No."
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_5 "Gross Weight"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_6 " Add Shipper "
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_7 "Ship-To"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_8 "Ship-From"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_9 "Shipper"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_10 "UM"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmta_p_11 "Volume"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*GUI moved mfdeclre/mfdtitle.*/
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* INPUT PARAMETERS */
define input parameter abs_recid as recid.

/* LOCAL VARIABLES */
define variable bill_no like abs_id no-undo.
define variable carrier as character format "X(10)" no-undo.
define variable id like abs_id label {&rcmbmta_p_4} no-undo.
define variable shipfrom like abs_shipfrom no-undo.
define variable refresh as logical no-undo.
define variable delyn as logical no-undo.

define variable confirm as character no-undo.

define variable wt_conv as decimal no-undo.
define variable vol_conv as decimal no-undo.
define variable disp_shipfrom like abs_shipfrom no-undo.

define variable disp_id like abs_id no-undo.
define variable carr_cdl1  as character no-undo.
define variable carr_cdl2  as character no-undo.
define variable ctr        as integer no-undo.
define variable sinmult    like mfc_logical format "1/2" initial 1 no-undo.
define variable single as character format "x(15)" no-undo.
define variable multi as character  format "x(15)" no-undo.

/* FROZEN SCHEMA VARIABLES */
{rcmbrpa.i}

define new shared temp-table shipselect no-undo
   field sel_idr        as character format "x(1)"
   field ab_master_id like abs_master_id
   field ab_id        like abs_id
   field ab_shipfrom  like abs_shipfrom
   field ab_shipto    like abs_shipto
   field ab_shp_date  like abs_shp_date
   field ab_shp_time  as character format "99:99"
   field ab_arr_date  like abs_arr_date
   field ab_arr_time  as character format "99:99" index sel1 sel_idr desc.


/* BUFFERS */
define buffer abs_line for abs_mstr.
define buffer abs_temp for abs_mstr.

assign
    confirm = getTermLabel("CONFIRM",8)
    single  = "1- " + getTermLabel("SINGLE",12)
    multi   = "2- " + getTermLabel("MULTI",12).

/* MASTER BILL INFORMATION FORM */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
disp_id               label {&rcmbmta_p_2} at 2
   abs_mstr.abs_shipfrom label {&rcmbmta_p_8}
   abs_mstr.abs_shipto   label {&rcmbmta_p_7}
 SKIP(.4)  /*GUI*/
with frame b side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

/* MAIN FORM */
FORM /*GUI*/ 
   disp_shipfrom       label {&rcmbmta_p_8}
   bill_no             label {&rcmbmta_p_9}
   abs_line.abs_shipto label {&rcmbmta_p_7}
   ad_name             format "x(16)"
   abs_line.abs_gwt
   abs_line.abs_wt_um  label {&rcmbmta_p_10}
with frame c width 80 attr-space 8 down scroll 1 BGCOLOR 8 /*GUI*/.


/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

/* ADD NEW SHIPPER FORM */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
shipfrom label {&rcmbmta_p_8} colon 11
   id       label {&rcmbmta_p_9} colon 11
 SKIP(.4)  /*GUI*/
with frame d 
attr-space width 36 side-labels overlay row 10 centered NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-d-title AS CHARACTER.
 F-d-title = (getFrameTitle("add_shipPER",17)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame d =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame d + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame d =
  FRAME d:HEIGHT-PIXELS - RECT-FRAME:Y in frame d - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME d = FRAME d:WIDTH-CHARS - .5. /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame d:handle).

FORM /*GUI*/ 
     
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
single skip
     multi
 SKIP(.4)  /*GUI*/
with frame x 
attr-space width 80 no-underline no-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-x-title AS CHARACTER.
 F-x-title = (getFrameTitle("SELECT_OPTION",30)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame x = F-x-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame x =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame x + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame x =
  FRAME x:HEIGHT-PIXELS - RECT-FRAME:Y in frame x - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME x = FRAME x:WIDTH-CHARS - .5. /*GUI*/



/* TOTAL WEIGHTS FORM */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
abs_mstr.abs_nwt    label {&rcmbmta_p_3}  colon 17
   abs_mstr.abs_wt_um  no-label
   abs_mstr.abs_gwt    label {&rcmbmta_p_5}  colon 17
   abs_mstr.abs_wt_um  no-label
   abs_mstr.abs_vol    label {&rcmbmta_p_11} colon 17
   abs_mstr.abs_vol_um no-label
 SKIP(.4)  /*GUI*/
with side-labels frame e width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-e-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame e = F-e-title.
 RECT-FRAME-LABEL:HIDDEN in frame e = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame e =
  FRAME e:HEIGHT-PIXELS - RECT-FRAME:Y in frame e - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME e = FRAME e:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame e:handle).

status input stline[13].

find abs_mstr where recid(abs_mstr) = abs_recid exclusive-lock.

assign
   disp_id = substring(abs_mstr.abs_id,2)
   refresh = true.

display
   disp_id
   abs_mstr.abs_shipfrom
   abs_mstr.abs_shipto
with frame b.

main:
do for abs_line:

   view frame c.
   do on error undo,retry on endkey undo,leave:
/*GUI*/ if global-beam-me-up then undo, leave.

      display single multi with frame x.
      /*ENTER SELECTION*/
      {pxmsg.i &MSGNUM=3651 &ERRORLEVEL= 1 &CONFIRM = sinmult
           &CONFIRM-TYPE='NON-LOGICAL'}
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

   hide frame x no-pause.
   hide message no-pause.


   if not sinmult then do:
      hide frame c no-pause.
      view frame b.
      {gprun.i ""rcshpsel.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      pause 0.
      for each shipselect where shipselect.sel_idr = "*" :
/*GUI*/ if global-beam-me-up then undo, leave.

         find abs_line where abs_line.abs_shipfrom = shipselect.ab_shipfrom
            and  abs_line.abs_id = "s" + shipselect.ab_id
         exclusive-lock no-error.
         if not available abs_line then next.
         assign
            wt_conv = 1
            vol_conv = 1.

         /* CONVERT UM IF NECESSARY */
         if abs_line.abs_wt_um <> abs_mstr.abs_wt_um then do:

            {gprun.i ""gpumcnv.p""
               "(input abs_line.abs_wt_um,
                 input abs_mstr.abs_wt_um,
                 input """",
                 output wt_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if wt_conv = ? then
               wt_conv = 1.
         end.

         vol_conv = 1.

         if abs_line.abs_vol_um <> abs_mstr.abs_vol_um then do:

            {gprun.i ""gpumcnv.p""
               "(input abs_line.abs_vol_um,
                 input abs_mstr.abs_vol_um,
                 input """",
                 output vol_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if vol_conv = ? then
               vol_conv = 1.

         end.
         assign
           abs_line.abs_master_id = abs_mstr.abs_id
           abs_mstr.abs_gwt = abs_mstr.abs_gwt + (abs_line.abs_gwt * wt_conv)
           abs_mstr.abs_nwt = abs_mstr.abs_nwt + (abs_line.abs_nwt * wt_conv)
           abs_mstr.abs_vol = abs_mstr.abs_vol + (abs_line.abs_vol * vol_conv)
           refresh = true.
     end.
/*GUI*/ if global-beam-me-up then undo, leave.

   end.
   mainloop:
   repeat with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.


      /* REFRESH THE DISPLAY SCREEN */
      if refresh then do:

         find first abs_line
            where abs_line.abs_master_id = abs_mstr.abs_id
         no-lock no-error.

         clear frame c all no-pause.
         view frame c.

         refresh:
         do while available abs_line and frame-line(c) <= 8:

            find ad_mstr where ad_addr = abs_line.abs_shipto
            no-lock no-error.

            display
               abs_line.abs_shipfrom        @ disp_shipfrom
               substring(abs_line.abs_id,2) @ bill_no
               abs_line.abs_shipto
               ad_name
                  when (available ad_mstr)
               abs_line.abs_gwt
               abs_line.abs_wt_um
            with frame c.

            if frame-line(c) = 8 then leave refresh.

            down 1 with frame c.

            find next abs_line where
               abs_line.abs_master_id = abs_mstr.abs_id
            no-lock no-error.

         end. /* DO WHILE AVAILABLE ABS_LINE */

         refresh = false.

         find first abs_line
            where abs_line.abs_master_id = abs_mstr.abs_id
         no-lock no-error.

         if frame-line(c) <> 0 then
            up frame-line(c) - 1 with frame c.

         display
            abs_mstr.abs_gwt
            abs_mstr.abs_nwt
            abs_mstr.abs_wt_um
            abs_mstr.abs_vol
            abs_mstr.abs_vol_um
         with frame e.

      end. /* IF REFRESH */

      if available abs_line then do:

         find ad_mstr where ad_addr = abs_line.abs_shipto
         no-lock no-error.

         display
            abs_line.abs_shipfrom        @ disp_shipfrom
            substring(abs_line.abs_id,2) @ bill_no
            abs_line.abs_shipto
            ad_name when (available ad_mstr)
            abs_line.abs_gwt
            abs_line.abs_wt_um
         with frame c.

      end.

      if lastkey = keycode("CURSOR-UP")
         or lastkey = keycode("F9")
         or lastkey = keycode("CURSOR-DOWN")
         or lastkey = keycode("F10") then do:

         /* Compare all header attirbutes of the two shippers and */
         /* warn if different                                     */

         /* Ship Via */
         if substring(abs_mstr.abs__qad01,1,20)   <>
            substring(abs_line.abs__qad01,1,20) or
            /* FOB */
            substring(abs_mstr.abs__qad01,21,20)   <>
            substring(abs_line.abs__qad01,21,20) or
            /* Trans Mode */
            substring(abs_mstr.abs__qad01,41,20)   <>
            substring(abs_line.abs__qad01,41,20) or
            /* Carrier Ref */
            substring(abs_mstr.abs__qad01,61,20)   <>
            substring(abs_line.abs__qad01,61,20) or
            /* Vehicle Ref */
            substring(abs_mstr.abs__qad01,81,20)   <>
            substring(abs_line.abs__qad01,81,20) or
            abs_mstr.abs_lang       <> abs_line.abs_lang
         then do:
            /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
            {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
         end.

         else do: /* if most attribs match */

            /* Build comma-delimited list of carriers and compare */
            for each absc_det where
                     absc_det.absc_abs_id = abs_mstr.abs_id
            no-lock:
               carr_cdl1 = "," + absc_carrier.
            end.

            for each absc_det where
                     absc_det.absc_abs_id = abs_line.abs_id
            no-lock:
               carr_cdl2 = "," + absc_carrier.
            end.

            if num-entries(carr_cdl1) <>
               num-entries(carr_cdl2)
            then do:
               /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
               {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
            end.
            else
               do ctr = 1 to num-entries(carr_cdl1):
               if lookup (entry(ctr,carr_cdl1), carr_cdl2) = 0
               then do:
                  /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
                  {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
                  leave.
               end.
            end.
         end. /* if most attribs match */
      end.
      set
         disp_shipfrom
         bill_no
      with frame c editing:

         readkey.

         if lastkey = keycode("F9")
         or keyfunction(lastkey) = "CURSOR-UP"
         or lastkey = keycode("F10")
         or keyfunction(lastkey) = "CURSOR-DOWN"
         or lastkey = keycode("F5")
         or lastkey = keycode("CTRL-D")
         or lastkey = keycode("F1")
         or lastkey = keycode("CTRL-X")
         or lastkey = keycode("PF1")
         or lastkey = keycode("F3")
         or lastkey = keycode("CTRL-T")
         or lastkey = keycode("PF3")
         or keyfunction(lastkey) = "GO"
         or keyfunction(lastkey) = "END-ERROR"
         or lastkey = keycode("F4")
         or lastkey = keycode("RETURN")
         or lastkey = keycode("CTRL-E") then
            leave.

      end. /* EDITING */

      if lastkey = keycode("F4")
      or keyfunction(lastkey) = "END-ERROR" then
         leave mainloop.

      /* ADD NEW SIMPLE BILL */
      if lastkey = keycode("F3")
         or lastkey = keycode("PF3")
         or lastkey = keycode("CTRL-T")
      then do:

         add_ship:
         do on endkey undo add_ship, leave add_ship
            on error undo add_ship, retry add_ship:
/*GUI*/ if global-beam-me-up then undo, leave.


            shipfrom = abs_mstr.abs_shipfrom.

            display
               shipfrom
            with frame d.

            set
               shipfrom id
            with frame d.

            find abs_temp where
                   abs_temp.abs_shipfrom = shipfrom
               and abs_temp.abs_id = "s" + id
               and abs_temp.abs_type = "s"
            exclusive-lock no-error.

            if locked(abs_temp) then do:
               /* RECORD LOCKED - TRY AGAIN LATER */
               {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=4}
               undo add_ship, retry add_ship.
            end.

            if not available abs_temp then do:
               /* SHIPPER DOES NOT EXIST */
               {pxmsg.i &MSGNUM=8119 &ERRORLEVEL=4}
               undo add_ship, retry add_ship.
            end.

            if abs_temp.abs_master_id <> "" then do:
               /* THIS SHIPPER HAS ALREADY ASSIGNED TO A MASTER BILL */
               {pxmsg.i &MSGNUM=8270 &ERRORLEVEL=4}
               undo add_ship, retry add_ship.
            end.

            /* Compare all header attirbutes of the two shippers and */
            /* warn if different                                     */

            /* Ship Via */
            if substring(abs_mstr.abs__qad01,1,20)   <>
               substring(abs_temp.abs__qad01,1,20) or
               /* FOB */
               substring(abs_mstr.abs__qad01,21,20)   <>
               substring(abs_temp.abs__qad01,21,20) or
               /* Trans Mode */
               substring(abs_mstr.abs__qad01,41,20)   <>
               substring(abs_temp.abs__qad01,41,20) or
               /* Carrier Ref */
               substring(abs_mstr.abs__qad01,61,20)   <>
               substring(abs_temp.abs__qad01,61,20) or
               /* Vehicle Ref */
               substring(abs_mstr.abs__qad01,81,20)   <>
               substring(abs_temp.abs__qad01,81,20) or
               abs_mstr.abs_lang       <> abs_temp.abs_lang
            then do:
               /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
               {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
            end.

            else do: /* if most attribs match */

               /* Build comma-delimited list of carriers and compare */
               for each absc_det where
                        absc_det.absc_abs_id = abs_mstr.abs_id
               no-lock:
                  carr_cdl1 = "," + absc_carrier.
               end.

               for each absc_det where
                        absc_det.absc_abs_id = abs_temp.abs_id
               no-lock:
                  carr_cdl2 = "," + absc_carrier.
               end.

               if num-entries(carr_cdl1) <>
                  num-entries(carr_cdl2)
               then do:
                  /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
                  {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
               end.
               else
                  do ctr = 1 to num-entries(carr_cdl1):
                  if lookup (entry(ctr,carr_cdl1), carr_cdl2) = 0
                  then do:
                     /* HEADER FIELD(S) OF SHIPPER HAVE DIFFERENT VALUES */
                     {pxmsg.i &MSGNUM=5815 &ERRORLEVEL=2}
                     leave.
                  end.
               end.
            end. /* if most attribs match */

            /* ASSIGN SHIPPER TO THIS MASTER BILL */
            abs_temp.abs_master_id = abs_mstr.abs_id.

            /* SET WEIGHT AND VOLUME UM IN MASTER BILL IF NONE */
            if abs_mstr.abs_vol_um = "" then
               abs_mstr.abs_vol_um = abs_temp.abs_vol_um.

            if abs_mstr.abs_wt_um = "" then
               abs_mstr.abs_wt_um = abs_temp.abs_wt_um.

            wt_conv = 1.

            /* CONVERT UM IF NECESSARY */
            if abs_temp.abs_wt_um <> abs_mstr.abs_wt_um then do:

               {gprun.i ""gpumcnv.p""
                  "(input abs_temp.abs_wt_um,
                    input abs_mstr.abs_wt_um,
                    input """",
                    output wt_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               if wt_conv = ? then
                  wt_conv = 1.
            end.

            vol_conv = 1.

            if abs_temp.abs_vol_um <> abs_mstr.abs_vol_um then do:

               {gprun.i ""gpumcnv.p""
                  "(input abs_temp.abs_vol_um,
                    input abs_mstr.abs_vol_um,
                    input """",
                    output vol_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               if vol_conv = ? then
                  vol_conv = 1.

            end.

            /* ADD ADDITIONAL WEIGHT */
            abs_mstr.abs_gwt = abs_mstr.abs_gwt + (abs_temp.abs_gwt * wt_conv).
            abs_mstr.abs_nwt = abs_mstr.abs_nwt + (abs_temp.abs_nwt * wt_conv).
            abs_mstr.abs_vol = abs_mstr.abs_vol + (abs_temp.abs_vol * vol_conv).

            refresh = true.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* add_ship */

         hide frame d no-pause.

         next mainloop.

      end. /* IF LASTKEY = KEYCODE F3 */

      /* REMOVE SIMPLE BILL */
      if (lastkey = keycode("F5")
      or lastkey = keycode("CTRL-D"))
         and available abs_line
      then do:

         delyn = yes.
         /* DELETE BILL # ARE YOU SURE? */
         {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=delyn
                  &CONFIRM-TYPE='LOGICAL'}

         /* REMOVE THE SHIPPER FROM THIS MASTER */
         if delyn then do:

            find abs_temp where recid(abs_temp) = recid(abs_line)
            exclusive-lock no-error.

            if locked(abs_temp) then do:
               /* RECORD LOCKED - TRY AGAIN LATER */
               {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=4}
               next mainloop.
            end.

            abs_temp.abs_master_id = "".

            release abs_temp.

            /* CONVERT UM IF NECESSARY */
            wt_conv = 1.

            if abs_line.abs_wt_um <> abs_mstr.abs_wt_um then do:
               {gprun.i ""gpumcnv.p""
                  "(input abs_line.abs_wt_um,
                    input abs_mstr.abs_wt_um,
                    input """",
                    output wt_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.

            if wt_conv = ? then
               wt_conv = 1.

            vol_conv = 1.

            if abs_line.abs_vol_um <> abs_mstr.abs_vol_um then do:
               {gprun.i ""gpumcnv.p""
                  "(input abs_line.abs_vol_um,
                    input abs_mstr.abs_vol_um,
                    input """",
                    output vol_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.

            if vol_conv = ? then
               vol_conv = 1.

            /* SUBTRACT WEIGHT FROM MASTER */
            abs_mstr.abs_gwt = abs_mstr.abs_gwt - (abs_line.abs_gwt * wt_conv).
            abs_mstr.abs_nwt = abs_mstr.abs_nwt - (abs_line.abs_nwt * wt_conv).
            abs_mstr.abs_vol = abs_mstr.abs_vol - (abs_line.abs_vol * vol_conv).

            refresh = true.

            find first abs_line where
               abs_line.abs_master_id = abs_mstr.abs_id
            no-lock no-error.

            next mainloop.

         end. /* IF DELYN THEN DO */

      end. /* IF LASTKEY = KEYCODE F5 */

      if lastkey = keycode("CURSOR-UP")
      or lastkey = keycode("F9") then do:

         find prev abs_line
             where abs_line.abs_master_id = abs_mstr.abs_id
         no-lock no-error.

         if not available abs_line then do:
            /* Beginning of file */
            {pxmsg.i &MSGNUM=21 &ERRORLEVEL=2}
            find next abs_line
                where abs_line.abs_master_id = abs_mstr.abs_id
            no-lock no-error.
         end.
         else
            up 1 with frame c.

         next mainloop.

      end.

      if lastkey = keycode("CURSOR-DOWN")
      or lastkey = keycode("F10") then do:

         find next abs_line
             where abs_line.abs_master_id = abs_mstr.abs_id
         no-lock no-error.

         if not available abs_line then do:
            /* End of file */
            {pxmsg.i &MSGNUM=20 &ERRORLEVEL=2}
            find prev abs_line where
                      abs_line.abs_master_id = abs_mstr.abs_id
            no-lock no-error.
         end.
         else
            down 1 with frame c.

         next mainloop.

      end.

      /* HANDLE GO KEY */
      if (lastkey   = keycode("F1")
      or lastkey = keycode("PF1")
      or lastkey = keycode("CTRL-X")
      or lastkey = keycode("RETURN")
      or keyfunction(lastkey) = "GO")
      then
      set_data:
      do on endkey undo set_data, leave set_data
         on error undo set_data, retry set_data:
/*GUI*/ if global-beam-me-up then undo, leave.

         /* MAINTAIN LOWER FRAME DATA */
         set
            abs_mstr.abs_nwt
            abs_mstr.abs_wt_um
            abs_mstr.abs_gwt
            abs_mstr.abs_wt_um
            abs_mstr.abs_vol
            abs_mstr.abs_vol_um
         with frame e.
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* set_data */

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* mainloop */

   hide frame b no-pause.
   hide frame c no-pause.
   hide frame d no-pause.
   hide frame e no-pause.

end. /* MAIN */
